<?php

namespace App\Models\Shop;

use Illuminate\Database\Eloquent\Model;

class Brand extends Model
{
    //黑名单
    protected $guarded = [];

    //一个品牌下有多个商品
    public function products()
    {
        return $this->hasMany('App\Models\Shop\Product');
    }

    //判断品牌下有没有商品
    static function check_products($id)
    {
        $brand = self::with('products')->find($id);
        if($brand->products->isEmpty()){
            return true;
        }
        return false;
    }

}
